<div id="main">
	
	<% if flash[:notice] %>
		<div id="notice"><p><%= flash[:notice] %></p></div>
	<% end %>
	
	<h2>Welcome <%= @current_user.name %></h2>
	<p>In the chatroomlist can you join a chatroom. If there is a arrow in front of the room, it's public. Else it's private
	and you need a password to join!<br/>
	Downunder you can create your own chatrooms. Either public or private. A chatroom will be deleted if alll users in it leave it.</p>
	
	<br/>
	<h3>Create new chatroom:</h3>
	<% form_for :chatroom, :url => {:action => 'create_chatroom'} do |f| %>
		<table id="create_chatroom">
			<tr>
				<td class="f"><label for="name">Name:</label></td>
				<td><%= f.text_field :name %></td>				
			</tr>
			<tr>
				<td class="f"><label>Private: </label></td>
				<td><%= f.radio_button :scope, 0, :onclick => "$('_password').show();$('_password_confirm').show();" %></td>
			</tr>
			<tr>
				<td class="f"><label>Public: </label></td>
				<td><%= f.radio_button :scope, 1, :onclick => "$('_password').hide();$('_password_confirm').hide();"%></td>
			</tr>
			
			<!-- is shown is private is choosen -->
			<tr id="_password" style="display:none;">
				<td class="f"><label for="password">Password:</label></td>
				<td><%= f.password_field :password %></td>
			</tr>
			<tr id="_password_confirm" style="display:none;">
				<td class="f"><label for="password_confirmation">Confirm:</label></td>
				<td><%= f.password_field :password_confirmation %></td>
			</tr>
			
			<tr>
				<td></td>
				<td><%= submit_tag 'Create' %></td>
			</tr>
			
		</table>
	<% end %>
	
</div>
<div id="sidebar">
	<h4>Active chatrooms</h4>
	<hr/>
	<% if @chatrooms.size == 0 %>
		<h4>No active chatrooms!</h4>
	<% else %>
	<table class="chatroomlist">
		<tr>
			<td width="10%"></td>
			<td><strong>Name</strong></td>
			<td><strong>Users</strong></td>
		</tr>
		<%= render :partial => '/partials/chatroom', :collection => @chatrooms %>
	</table>
	<% end %>
</div>
